/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.javatrainning.duongnt.b1;

/**
 *
 * @author ThuyDuong
 */
public class Bai8Muc1Co7chuso {
       public static boolean ngto(long a) {
        if(a<=1) return false;
        for (int i = 2; i <= Math.sqrt(a); i++) 
        if (a % i == 0)
         return false;
        return true;
    }
     public static boolean chusodeungto(long a){
        long i;
        while(a>0){
            i = a%10;
            if(ngto(i)==false) return false;
            a /= 10;
        }
        return true;
    }  
     public static boolean daykhonggiam(long a){
         long du,i;
         i=a%10;
         a=a/10;
        while(a>0){
                     du=a%10;
                     if(du>i)return false;
                     i=du;
                     a/=10;
         }
       return true;
         
     }
     public static void main(String[] args) {
         long i;
         for(i = 1000000; i <10000000; i++){
             if(ngto(i)==true && chusodeungto(i)==true && daykhonggiam(i)==true)System.out.println(i);
         }
}
}
